package com.zoe.app.filters;

import com.zoe.app.context.BaseContext;
import lombok.RequiredArgsConstructor;

import java.util.Collection;

/**
 * @author zbg
 * @date 2023/06/06
 * @description
 */
@RequiredArgsConstructor
public abstract class AbsFilterChain<C extends BaseContext, F extends BaseFilter<C>> implements IBaseFilterChain<C> {
    protected final Collection<F> collection;

    @Override
    public void fireFilter(C ctx) {
        for (F f : collection) {
            if (!ctx.continueChain()) {
                continue;
            }
            f.doFilter(ctx);
        }
    }
}
